package com.xiyin.methods;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;


public class MyMethods extends AbstractMethod{

    public MyMethods() {
        super("selectAll");
    }
    protected MyMethods(String methodName) {
        super(methodName);
    }

    @Override
    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
        //定义SQL语句
        String sql = "select * from " + tableInfo.getTableName();
        System.out.println("5555555555555555:"+sql);
        //方法名
        String methodName = "selectAll";
        //构建SqlSource，将SQL语句传递到数据库中
        SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sql, modelClass);
        //构建查询方法
        return this.addSelectMappedStatementForTable(mapperClass, methodName, sqlSource, tableInfo);
    }
}